package cn.com.bluemoon.daps.system.controller;


import cn.com.bluemoon.daps.common.datascope.BmPermission;
import cn.com.bluemoon.daps.common.domain.ResultBean;
import cn.com.bluemoon.daps.system.entity.DapSystemDepartment;
import cn.com.bluemoon.daps.system.service.DapSystemDepartmentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 部门管理表 前端控制器
 * </p>
 *
 * @author admin
 * @since 2020-08-04
 */
@Api(tags = "部门管理")
@RestController
@Slf4j
@RequestMapping("/dapSystemDepartment")
public class DapSystemDepartmentController {
    @Resource
    private DapSystemDepartmentService dapSystemDepartmentService;

    @GetMapping("/list")
    @ApiOperation(value = "获取部门信息")
    @BmPermission(value = "list", name = "获取部门信息", ignore = true)
    @ApiResponses(value = {@ApiResponse(code = 200, message = "ok", response = DapSystemDepartment.class)})
    public ResultBean<List<DapSystemDepartment>> list(){
        return ResultBean.ok(dapSystemDepartmentService.list());
    }

    @GetMapping("/getById/{id}")
    @ApiOperation(value = "获取部门信息")
    @ApiResponses(value = {@ApiResponse(code = 200, message = "ok", response = DapSystemDepartment.class)})
    public ResultBean<DapSystemDepartment> getById(@PathVariable String id){
        DapSystemDepartment sysDept = dapSystemDepartmentService.getById(id);
        return ResultBean.ok(sysDept);
    }

}
